#include "NamedAction.h"

#include <QDebug>

namespace falcon {

const QString& NamedAction::group() const {
    return _group;
}

const QString& NamedAction::name() const {
    return _name;
}

void NamedAction::naming(const QString& fname) {
    auto names = fname.split(QChar('.'));
    Q_ASSERT(names.size() == 2);
    qDebug() << "******" << fname << ":" << names[0] << "," << names[1];
    _group = names[0];
    _name = names[1];
}

QString NamedAction::fullName() const {
    return QString("%1,%2").arg(_group).arg(_name);
}

NamedAction::NamedAction(const QString& name, QObject* parent)
    : QAction(parent) {
    naming(name);
}

NamedAction::NamedAction(const QString& name, const QString& text, QObject* parent)
    : QAction(text, parent) {
    naming(name);
}

NamedAction::NamedAction(const QString& name, const QIcon& icon, const QString& text, QObject* parent)
    : QAction(icon, text, parent) {
    naming(name);
}

} // namespace falcon